<template>
  <div>
    <van-field
      v-model="password"
      center
      clearable
      placeholder="请输入密码"
    >
    </van-field>
    <van-button round class="btn" block color="#ff6666" @click="submit" :disabled="flag">下一步</van-button>
  </div>
</template>

<script>
import Vue from 'vue'
import { NavBar, Field, Button } from 'vant'
import { doFinishRegister } from '../../api/user'

Vue.use(NavBar)
Vue.use(Field)
Vue.use(Button)

export default {
  data () {
    return {
      flag: true,
      password: ''
    }
  },
  methods: {
    async submit () {
      console.log(this.password)
      const subRes = await doFinishRegister({ tel: localStorage.getItem('tel'), password: this.password })
      console.log(subRes)
      this.$router.push('/home')
    }
  },
  watch: {
    password (newV) {
      // console.log(newV)
      if (newV.length >= 6) {
        this.flag = false
      } else {
        this.flag = true
      }
    }
  }
}
</script>

<style lang="stylus" scoped>
.content
  padding 30px 20px
</style>
